import React from 'react'
import { Carousel } from 'antd-mobile';
import {get} from 'api/http'

export default class App extends React.Component {
  state = {
    data: []
  }

 async getSwiper(){
   let rs = await get('/api/swiper')
   this.setState({
     data:rs.data.datalist
   })
  }

  componentDidMount() {
    this.getSwiper()
  }
  render() {
    return (
        <Carousel
          autoplay={true}
          infinite={true}
        >
          {this.state.data.map((val,index) => (
           
              <img
              key={index}
                src={val.img}
                alt={index}
                style={{ width: '100%', verticalAlign: 'top' }}
                onLoad={() => {
                  this.setState({ imgHeight: 'auto' });
                }}
              />
          ))}
        </Carousel>
    )
  }
}